package com.iengoo.day13.ctrl;

import com.iengoo.day13.service.ServletService;
import com.iengoo.day13.service.impl.ServletServiceImpl;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author zpym
 * @CopyRight (C) http://www.iengoo.com
 * @brief
 * @email 122162005@qq.com
 * @date 2019-01-25 15:00
 */
public class HelloServlet implements Servlet {
    private ServletService service = new ServletServiceImpl();

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        // 从响应对象获取输出流,他的作用是向浏览器输出服务端的数据
        PrintWriter writer = servletResponse.getWriter();
        writer.println(service.hello());
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
